package com.levenx.vo;

import com.levenx.vo.support.DefaultPageResult;
import com.levenx.vo.support.DefaultResult;
import com.levenx.vo.support.FileResult;

public interface Result<T> {

    boolean isSuccess();

    int status();

    Result<?> ofStatus(int status, String massage);

    static Result<?> newResult() {
        return new DefaultResult();
    }

    static <T> Result<T> newResult(T data) {
        return new DefaultResult<>(data);
    }

    static <T> Result<T> newFileResult(String src, String name) {
        return new FileResult(src, name);
    }

    static <T> Result<T> newFileResult(String src) {
        return new FileResult(src, "default");
    }

    static <T> Result<T> newPageResult(int pn, int ps, long count, T data) {
        return new DefaultPageResult(pn, ps, count, data);
    }

    static <T> Result<T> status(int code, String msg) {
        return new DefaultResult<>(code, msg);
    }
}
